// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import ElementUI from 'element-ui';
import  'element-ui/lib/theme-chalk/index.css';

import axios from  'axios';
import VueAxios from 'vue-axios';


Vue.use(VueAxios, axios)
Vue.prototype.$axios = axios;
axios.defaults.baseURL = 'http://localhost:8080/BMS';
axios.defaults.headers.post['Content-Type'] = 'application/json';
Vue.config.productionTip = false
Vue.use(router);
Vue.use(ElementUI);

router.beforeEach((to, from, next) => {
  console.log(to);
  console.log(from);
  if (to.meta.requireAuth) { // 判断该路由是否需要登录权限
    if(localStorage.getItem('admin')){ //判断本地是否存在access_token
      next();
    }else {
     if(to.path === '/Login'){
        next();
      }else {
        next({
          path:'/Login'
        })
      }
    }
  }
  else {
    next();
  }
 
});




new Vue({
  el: '#app',
  router,
 render:h=> h(App)//ElementUI
});
